package yl.hs.bmipfull.controllers.vehiclemanage;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import yl.hs.bmipfull.controllers.ControllerBase;
import yl.hs.bmipfull.service.vehiclemanage.ITransSystemLogService;
import yl.hs.bmipfull.viewmodels.PageQuery;
import yl.hs.bmipfull.viewmodels.WebResult;

/**
 * 作用:  运输系统日志控制层<br/>
 * 创建时间: 2021年06月08日 15时10分37秒 <br/>
 *
 * @author 张凯
 */
@Api(value = "运输系统日志Web接口", tags = "运输管理——运输系统日志操作")
@RequestMapping(value = "/api/transSystemLog")
@RestController
public class TransSystemLogController extends ControllerBase {

    @Autowired
    ITransSystemLogService service;

    @ApiOperation(value = "查询运输系统日志", notes = "查询运输系统日志")
    @RequestMapping(value = "", method = RequestMethod.POST)
    public WebResult queryList(@ApiParam(value = "查询条件") @RequestBody PageQuery pageQuery) {
        try {
            return success("查询成功", service.queryList(pageQuery));
        } catch (Exception e) {
            return error(e);
        }
    }

    @ApiOperation(value = "查询运输系统日志", notes = "分页查询运输系统日志")
    @RequestMapping(value = "/{rowNum}/{page}", method = RequestMethod.POST)
    public WebResult queryPage(@RequestBody PageQuery query,
                               @ApiParam(value = "页码") @PathVariable int page,
                               @ApiParam(value = "每页条数") @PathVariable int rowNum) {
        try {
            var result = service.queryPage(query, rowNum, page);
            return success("ok", result);
        } catch (Exception ee) {
            return error(ee);
        }
    }


    @ApiOperation(value = "查询运输系统日志", notes = "根据数据编号编号查询操作日志")
    @RequestMapping(value = "/{dataSn}", method = RequestMethod.GET)
    public WebResult findBySn(@ApiParam(value = "数据编号") @PathVariable String dataSn) {
        return success("查询成功", service.queryByDataSn(dataSn));
    }

}